package com.community.process._1010.common.utils.mp;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oneadds.lowcode.dto.PageListData;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Schema(description = "MpPageFormat转换器")
public class MpPageFormat<T> extends PageListData<T> {

    @Schema(description = "当前页")
    private long currentPage;

    @Schema(description = "分页总数")
    private long pageCount;

    public MpPageFormat(IPage<T> page) {
        super(page.getSize(),page.getTotal(),page.getRecords());
        this.currentPage=page.getCurrent();
        this.pageCount=page.getPages();
    }

    public static <T> MpPageFormat<T> format(IPage<T> page) {
        return new MpPageFormat<>(page);
    }
}
